/*
day252
2020.5.6
*/
#include<vector>
#include<cstdlib> 
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution {
public:
    bool isSubStructure(TreeNode* A, TreeNode* B) {
    	if(!A || !B)
    	{
    		return false;
		}
		
		if(equal(A,B))
		{
			return true;
		}
		
		return isSubStructure(A->left,B) || isSubStructure(A->right,B);
    }
    
    bool equal(TreeNode* A, TreeNode* B)
    {
    	if(!B)
    	{
    		return true;
		}
		
		if(!A || A->val != B->val)
		{
			return false;
		}
		
		return equal(A->left,B->left) && equal(A->right,B->right);
	}
};

int main()
{
	return 0;
}
